package com.suoluo.zenadmin.dao.friend;

import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;

import com.suoluo.zenadmin.vo.friend.FriendItemVO;
import com.suoluo.zenadmin.vo.friend.FriendTypeVO;

@DAO
public interface FriendDAO {

	@SQL("select * from tb_friend_type")
	public List<FriendTypeVO> findListFriendType();
	
	@SQL("insert into tb_friend_type(t_friend_type_name) values(:1.friendTypeName)")
	public void saveFriendType(FriendTypeVO typePOJO);
	
	@SQL("select * from tb_friend_type where t_friend_type_id=:1")
	public FriendTypeVO findFriendTypeById(int typeId);
	
	@SQL("update tb_friend_type set t_friend_type_name=:1.friendTypeName " +
			"where  t_friend_type_id=:1.friendTypeId")
	public void updateFriendType(FriendTypeVO typePOJO);
	
	@SQL("delete from tb_friend_type where t_friend_type_id=:1")
	public void deleteFriendType(int typeId);
	
	@SQL("select * from tb_friend_item where t_friend_type_id=:1")
	public List<FriendItemVO> findListFriendItem(int typeId);
	
	@SQL("insert into tb_friend_item(t_friend_type_id,t_friend_item_name," +
			"t_friend_item_url,t_friend_item_order,t_friend_orig_img,t_icon) " +
			"values(:1.friendTypeId,:1.friendItemName," +
			":1.friendItemUrl,:1.friendItemOrder,:1.friendOrigImg,:1.icon)")
	public void saveFriendItem(FriendItemVO itemVO);
	
	@SQL("select * from tb_friend_item where t_friend_item_id=:1")
	public FriendItemVO findFriendItemById(int itemId);
	
	@SQL("update tb_friend_item set t_friend_item_order=:2 where " +
			"t_friend_type_id=:1 and t_friend_item_order=:3")
	public void updateItemOrder(int typeId,int oldOrder,int newOrder);
	
	@SQL("update tb_friend_item set t_friend_item_name=:1.friendItemName," +
			"t_friend_item_url=:1.friendItemUrl,t_icon=:1.icon," +
			"t_friend_item_order=:1.friendItemOrder,t_friend_orig_img=:1.friendOrigImg " +
			"where t_friend_item_id=:1.friendItemId")
	public void updateFriendItem(FriendItemVO itemVO);
	
	@SQL("delete from tb_friend_item where t_friend_item_id=:1")
	public void deleteFriendItem(int itemId);
	@SQL("select max(t_friend_item_order) from tb_friend_item")	
	public int findFriendItemMaxOrder();
}
